package cn.tiancaifan.micro.service;


import cn.tiancaifan.micro.entity.Department;
import cn.tiancaifan.micro.mapper.DepartmentMapper;
import cn.tiancaifan.micro.utils.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (Department)表服务接口
 *
 * @author makejava
 * @since 2020-05-27 09:40:33
 */
@Service
public class DepartmentService {

    @Autowired
    DepartmentMapper departmentMapper;

    public List<Department> getAllDepartment() {
        return departmentMapper.getAllDepartmentsByParentId(-1);
    }

    @Logger("添加部门")
    public void addDep(Department dep) {
        dep.setEnabled(true);
        departmentMapper.addDep(dep);
    }

    @Logger("删除部门")
    public void deleteDepById(Department dep) {
        departmentMapper.deleteDepById(dep);
    }
}